package com.kaifamiao.demo.d0718;

import java.util.Scanner;

public class Ex01 {

    public static void main(String[] args) {
        // 打印一个等腰三角形  5 行， 根据输入打印 （row > 3）

        /*                           (row-r) * 2 + 1   (2r - 1)
          |       *           r = 1,    space = 7 ,     * = 1
          |     * * *         r = 2,    space = 5,      * = 3
          |   * * * * *       r = 3,    space = 3,      * = 5
          | * * * * * * *     r = 4,    space = 1,      * = 7
        */
        Scanner in = new Scanner(System.in);
        System.out.println("请输入行数：");
        int row = in.nextInt();
        // 控制几行
        for (int r = 1; r <= row; r ++){

            String spaceStr = "";
            String starStr = "";
            // 打印空白
            for(int space = 0; space < (row - r) * 2 + 1; space ++){
                spaceStr += " ";
            }

            // 打印 *
            for (int star = 0; star < 2 * r - 1; star ++){
                starStr += "* ";
            }

            System.out.print(spaceStr);
            System.out.println(starStr);
        }

    }
}
